<link href="/css/bootstrap.min.css" rel="stylesheet"/>  
<link href="/templates/admin/css/admin_default.css" rel="stylesheet"/> 
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/CLEditor1_4_2/jquery.cleditor.min.js"></script>
<link href="/js/CLEditor1_4_2/jquery.cleditor.css" rel="stylesheet"/>
<script type="text/javascript">
    var obj = {
        width:        500, // width not including margins, borders or padding
        height:       100, // height not including margins, borders or padding
        controls:     // controls to add to the toolbar
          "bold italic underline strikethrough subscript superscript | font size " +
          "style | color highlight removeformat | bullets numbering | outdent " +
          "indent | alignleft center alignright justify ",
        colors:       // colors in the color popup
          "FFF FCC FC9 FF9 FFC 9F9 9FF CFF CCF FCF " +
          "CCC F66 F96 FF6 FF3 6F9 3FF 6FF 99F F9F " +
          "BBB F00 F90 FC6 FF0 3F3 6CC 3CF 66C C6C " +
          "999 C00 F60 FC3 FC0 3C0 0CC 36F 63F C3C " +
          "666 900 C60 C93 990 090 399 33F 60C 939 " +
          "333 600 930 963 660 060 366 009 339 636 " +
          "000 300 630 633 330 030 033 006 309 303",
        fonts:        // font names in the font popup
          "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," +
          "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",
        sizes:        // sizes in the font size popup
          "1,2,3,4,5,6,7",
        styles:       // styles in the style popup
          [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"],
            ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
            ["Header 6","<h6>"]],
        useCSS:       false, // use CSS to style HTML when possible (not supported in ie)
        docType:      // Document type contained within the editor
          '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
        docCSSFile:   // CSS file used to style the document contained within the editor
          "",
        bodyStyle:    // style to assign to document body contained within the editor
          "margin:4px; font:10pt Arial,Verdana; cursor:text"}
          
    $(document).ready(function () { $(".card_content").cleditor(obj).updateTextArea; });
  </script>
  
<?php $film=$this->film; foreach($film as $item){;?> 

<form name="editor" action="/admin/index/doneedit" method="post" enctype="application/x-www-form-urlencoded">     
<div id="main-content">
<div class="content">
    <input type="text" value="<?php echo $item['id'];?>"  name='id' style='display:none'/>
</div>

<div class="news-content">
    <label>Trạng thái:</label>
      <div>
               <select name="status">
                <option value="1" <?php if ($item['status'] == '1') echo "selected = 'selected'"?> >ON</option>
                <option value="0" <?php if ($item['status'] == '0') echo "selected = 'selected'"?>>OFF</option>
                </select>
            </div>
</div>

<div class="news-content">
    <label>Loại play:</label>
      <div>
               <select name="typeplay">
                <option value="1" <?php if ($item['typeplay'] == '1') echo "selected = 'selected'"?>>Chơi video</option>
                <option value="2" <?php if ($item['typeplay'] == '2') echo "selected = 'selected'"?>> video + mp3</option>
                <option value="3" <?php if ($item['typeplay'] == '3') echo "selected = 'selected'"?>> Mp3</option>
                </select>
            </div>
</div>

<div class="news-content">
            <label>Lựa chọn Category:</label>
            <div>
               <select name="select-category" id="select-category">
               <?php foreach($this->listType as $filmtype){ 
                    $item_type = explode('|',$item['type']);
                ?>
                <option value="<?php echo $filmtype['id']?>" <?php  if ($item_type['0']==$filmtype['id']) echo "selected='selected'"?>><?php echo $filmtype['name']?></option>
                <?php }?>
                </select>
            </div>
</div>
<script>
    $("#select-category").change(function () {
          var str = "1";
          var scntDiv = $('#select-box');
          $("#select-category option:selected").each(function () {
                str = $(this).val();
                $(".cate-all").css('display','none');
                $("#cate-"+str).css('display','block')
              });
    })
        .trigger('change');
</script>
<?php
        foreach($this->listType as $type){
            $item_type = explode('|',strip_tags($item['type']));
            $item_types = explode('|',strip_tags($type['name_types']));
            for($i = 0;$i < count($item_types); $i++){
                    $item_types[$i] = explode('-',$item_types[$i]);
            };
            $count = count($item_types);
?>
<div class="news-content cate-all" id="cate-<?php echo $type['id']?>" style="display: <?php if($type['id']==$item_type['0'])echo"block";else echo"none"; ?>;">
            <label>Lựa chọn chuyên mục:</label>
            <div>
            <select multiple="multiple" name="select-type-<?php echo $type['id']?>[]" id="select-type-<?php echo $type['id']?>">
<?php
            for($i = 0;$i<$count;$i++){
?>
            <option value="<?php echo $item_types[$i][0]?>" <?php for($j = 1;$j<count($item_type);$j++){if ($item_type[$j] == $item_types[$i][0]) echo "selected='selected'";}?>><?php echo $item_types[$i][1] ?></option>
<?php       }
            ?>
           </select>
            </div>
</div>  
<?php
        };
?>

<div class="news-content">
    <label>Tiêu đề việt:</label>
<!--     <input type='text' name="header" value="<?php echo $item['title_vi'] ?>"/>
-->     <textarea class="textarea1" name="title_vi"><?php echo $item['title_vi'] ?></textarea>
</div>
<div class="news-content">
    <label>Tiêu đề Tiếng anh:</label>
<!--     <input type='text' name="header" value="<?php echo $item['title_en'] ?>"/>
-->     <textarea class="textarea1" name="title_en"><?php echo $item['title_en'] ?></textarea>
</div>

<div class="news-content">
    <label>Năm phát hành: </label>
    <input type="text"  id="year" name="year" value="<?php echo stripslashes($item['year']);?>"/>
</div>

<div class="news-content">
    <label>Quốc gia/ Ca sĩ:</label>
    <input type="text"  id="national" name="national" value="<?php echo stripslashes($item['national']);?>"/>
</div>
<div class="news-content">
    <label>
    Nguồn *
    </label>
    <input type="text"  id="source" name="source" value="<?php echo stripslashes($item['source']);?>" required="required"/>
</div>
<div class="news-content">
    <label>Banner:</label>
    <?php
        $banners = stripslashes($item['banner']);
        $banners =  explode('|',$banners,2);
        //Zend_Debug::dump($banners);die
     ?>
    <input type="text"  id="banner" name="banner" value="<?php if($banners[0] != 'ON') echo $banners[0];else echo $banners[1]?>"/>
    <input type="checkbox" name="check-banner" id="check-banner" <?php if($banners[0] == 'ON') echo "checked"?>/>
</div>

<div class="news-content">
    <label>Chọn ảnh:</label>
    <input type="text" value="<?php echo $item['thumb'];?>" id="urlSelectImg" name="urlSelectImg" style="display: none;" />
    <input type="button" value="Upload" id="btnSelectImg" name="btnSelectImg" class="btn btn-success" />
    <div id="displayImages"><img height=72 width=72 class='images' src="<?php echo $item['thumb'];?>"/></div>
</div>
<!--
<div class="news-content">
    <label>Ngày đăng:</label>

   <input type="text" name="date" id="inputDate" value="<?php echo $item['date']; ?>" />


<script type="text/javascript">
    var date= new Date();
    var year_now= date.getFullYear();
    $('#inputDate').datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "1900:2100",
    dateFormat: "dd-mm-yy",
    monthNamesShort: ['tháng 1','tháng 2','tháng 3','tháng 4','tháng 5', 'tháng 6','tháng 7','tháng 8','tháng 9','tháng 10','tháng 11','tháng 12']
});


</script>
</div>-->
<div class="news-content">
    <label>Kiểu video</label>
    <?php echo $this->formSelect("type_data_ep",$item['type_data_ep'],null,array("0"=>"Link Youtube","1"=>"Mã nhúng",))?>
    <span style="color: red;margin-left: 8px;">***Chú ý chọn đúng kiểu dữ liệu của video</span>
</div>
<div class="news-content">
    <label>Số tập phim:</label>
    <input readonly="readonly" type="text"  id="number_ep" name="number_ep" value="<?php echo stripslashes($item['number_ep']);?>"/>
    <input readonly="readonly" type="hidden"  id="old_ep" name="old_ep" value="<?php echo stripslashes($item['number_ep']);?>"/>
    <input readonly="readonly" type="hidden"  id="del_ep" name="del_ep" value="0"/>
    <input readonly="readonly" type="hidden"  id="add_ep" name="add_ep" value="0"/>
</div>
<div id="div_scents">
<?php   
if($item['type_data_ep'] == 0){
        $urls = explode('|',stripslashes($item['url_eps']));
}else{
    $urls = explode('#|#',stripslashes($item['url_eps']));
}
        $des = explode('#|#',stripslashes($item['des_eps']));
        $num = intval(stripslashes($item['number_ep']));
        $card = explode('#|#',stripslashes($item['card']));
        $mp3 = explode('#|#',stripslashes($item['mp3']));
        for($i =1;$i<=$num ;$i++){
            echo "<div class='news-content'><label for='ep-".$i."'>Link/ Mã nhúng tập ".$i.":</label><input placeholder='Tiêu đề' type='text' id='des-".$i."'  size='20' name='des-".$i."' value='".@$des[$i-1]."' /><textarea class='textarea' id='ep-".$i."' size='20' name='ep-".$i."'>".@$urls[$i-1]."</textarea><textarea class='card_content textarea_ep' placeholder='Mã nhạc chờ' id='card-".$i."' name='card-".$i."'>".@$card[$i-1]."</textarea>
            <textarea class='textarea' placeholder='link nhac mp3' id='mp3-".$i."' name='mp3-".$i."'>".@$mp3[$i-1]."</textarea>
            <a href='#' id='remScnt'> Xóa</a></div>";
        }
 ?>
 </div>
 <h2><a href="#" id="addScnt"><button>Thêm tập</button></a></h2>
 <script>
	$(document).ready(function(){
        var scntDiv = $('#div_scents');
        var i = $('#div_scents div').size()/34 + 1;
        var del = parseInt($('#del_ep').val());
        var add = parseInt($('#add_ep').val());
        var number_ep = parseInt($('#number_ep').val());
        $('#addScnt').live('click',function() {
                add = parseInt($('#add_ep').val());
                $('#add_ep').val(add + 1);
                number_ep = parseInt($('#number_ep').val());
                $('#number_ep').val(number_ep+1);
                
                $('<div class="news-content"><label for="ep-'+i+'">Link/ Mã nhúng tập '+i+':</label><input placeholder="Tiêu đề" type="text" id="des-'+i+'" size="20" name="des-' + i +'" value="" /><textarea class="textarea" placeholder="Link/ Mã nhúng" type="text" id="ep-'+i+'" size="20" name="ep-' + i +'"></textarea><textarea class="card_content" placeholder="Mã nhạc chờ" id="card-'+i+'" name="card-'+i+'"></textarea><textarea class="textarea" placeholder="link_mp3" id="mp3-'+i+'" name="mp3-'+i+'"></textarea><a href="#" id="remScnt" class="'+i+'"> Xóa</a></div>').appendTo(scntDiv);
                $('#number_ep').val(i);
                i++;
                $(".card_content").cleditor(obj);
                return false;
        });
        $('#remScnt').live('click', function() {
                if( i-del > 2 ) {
                        $(this).parents('div.news-content').remove();
                        
                        del = parseInt($('#del_ep').val());
                        $('#del_ep').val(del + 1);
                        
                        number_ep = parseInt($('#number_ep').val());
                        $('#number_ep').val(number_ep-1);
                }
                return false;
        });
});
</script>
 <!--
<script>
    var value = 0;
    $("#number_ep").keyup(function () {
      var scntDiv = $('#div_scents');        
      value = $(this).val();
      for(var i=1; i<=value;i++){
        $('<div class="news-content"><label for="ep-'+i+'">Link tập '+i+':</label><input type="text" id="ep-'+i+'" size="20" name="ep-' + i +'" value="" /></div>').appendTo(scntDiv);
      
    }).keyup();
</script>
-->
<div class="mo-ta">
    <label>Mô tả:</label>
    <textarea  id="newscontent" name="description"><?php echo stripslashes($item['description']);?></textarea>
</div>
<div class="mo-ta">
    <label>Từ khóa:</label>
    <textarea  id="newscontent" name="keywords"><?php echo stripslashes($item['keywords']);?></textarea>
</div>
<div class="news-content">
    <input type="submit" value="Ðăng bài" class="btn btn-success"/>
</div>
</div>
<?php }?>
</form>
 <script>
               CKEDITOR.replace('newscontent',{
                   fullpage:true,
                   extraPlugins:'docprops',
                   skin:'office2003',
                   
                   extraPlugins : 'autogrow',
	               autoGrow_maxHeight : 600,
                   removePlugins : 'resize'
               });
    </script>
 